-module(p25).
-compile(export_all).

result() -> 
    List = fibonacci(fun is_1000_digits/2),
    lists:flatlength(List).

is_1000_digits(F1, _F2) ->
    List = erlang:integer_to_list(F1),
    lists:flatlength(List) =:= 1000.

fibonacci(Bound_fun) -> fibonacci_list([1, 1], Bound_fun).
    
fibonacci_list([F1, F2 | _T]=Z, Bound_fun) ->
    case Bound_fun(F1, F2) of
        true -> Z;
        false -> fibonacci_list([F1 + F2 | Z], Bound_fun)
    end.
